#include "mythread.h"
#include "ui_widget.h"

#include <QPixmap>
#include <QtDebug>
#include <QSize>

MyThread::MyThread(QObject *parent) : QThread(parent), dir("/mnt/hgfs/pic")
{
    list = dir.entryList();
//    qDebug() << list;
    list.removeAll(".");
    list.removeAll("..");
}

MyThread::~MyThread()
{

}

void MyThread::setUi(Ui::Widget *ui)
{
    this->ui = ui;
}

void MyThread::run()
{
    for(int i = 0;; i++)
    {
        i %= list.size();
        QString mapstr = "/mnt/hgfs/pic/" + list.at(i);
//        qDebug() << mapstr;

        QPixmap pixmap(mapstr);
        pixmap = pixmap.scaled(ui->label->size(), Qt::KeepAspectRatio);

//        ui->label->setScaledContents(true);//无视图片大小使图片填满整一个label
        ui->label->setPixmap(pixmap);
        sleep(1);
        qDebug() << "线程开始";
    }
}



